package com.tanhua.model.vo;

import com.tanhua.model.db.UserInfo;
import com.tanhua.model.mongo.RecommendUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class CardVo implements Serializable {

    private Long id; //用户id

    private String avatar; //用户头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String[] tags; //用户标签：多个用逗号分隔


    /**
     * 在vo对象中，补充一个工具方法，封装转化过程
     */
    public static CardVo init(UserInfo userInfo) {
        CardVo vo = new CardVo();
        BeanUtils.copyProperties(userInfo,vo);
        if(userInfo.getTags() != null) {
            vo.setTags(userInfo.getTags().split(","));
        }
        return vo;
    }
}
